# -*- coding: utf-8 -*-
# https://blog.csdn.net/weixin_52040868
# 公众号：测个der
# 微信：qing_an_an

import sys
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.Qt import *


class Bar(QMainWindow):
    def __init__(self):
        super(Bar, self).__init__()
        self.setWindowTitle("QToolBar 示例")
        self.resize(300, 200)

        layout = QVBoxLayout()

        tb = self.addToolBar("File")
        # 添加图形按钮
        open_ = QAction(QIcon('文件夹.png'), 'open', self)
        tb.addAction(open_)

        save = QAction(QIcon("保存.png"), "save", self)
        tb.addAction(save)

        help = QAction(QIcon("帮助.png"), "help", self)
        tb.addAction(help)
        # 图形对象点击触发自定义槽函数
        tb.actionTriggered[QAction].connect(self.perssed)

        self.setLayout(layout)

    def perssed(self, a):
        print("pressed tool button is ", a.text)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    bar = Bar()
    bar.show()

    sys.exit(app.exec_())
